package dynamicFields;

import java.awt.Dimension;
import java.util.ArrayList;

import javax.swing.BoxLayout;
import javax.swing.JPanel;

import Models.Recipe;

public class EntryList extends JPanel {
	public static final String BASIC = "Basic"; //used for basic fields that all recipes have
	
	private String[] titles = {"ID:", "Style:", "OG:", "FG:", "IBU:", "Pre Boil Vol:", "Post Boil Vol:",
			"Boil Time:", "Mash Temp:", "Mash Time:", "Efficiency:", "Brew Date:"};

	private Recipe rec;
	
	ArrayList<Entry> entries;
	
	public EntryList(String type) {
		this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		entries = new ArrayList<Entry>();
		if(type.equals(BASIC)) {
			generateBasicEntries();
		}
	}
	
	public void addItem(Entry entry) {
		entries.add(entry);
		this.add(entry);
	}
	
	private void generateBasicEntries() {
		int length = titles.length;
		for(int i = 0; i < length; i++) {
			addItem(new BasicEntry(this, titles[i]));
		}
	}
	
	/**
	 * Removes the entry from the list
	 * @param entry
	 */
	public void removeItem(Entry entry) {
		 entries.remove(entry);
		 remove(entry);
		 revalidate();
	}
}
